<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 递归的使用
        fn3(3)
        function fn3(m){
            console.log(m);
            if(m > 0){
                fn2(m-1);
            }
            console.log(m);
        }

        function fn2(m){
            console.log(m);
            if(m > 0){
                fn1(m-1);
            }
            console.log(m);
        }

        function fn1(m){
            console.log(m);
            if(m > 0){
                fn0(m-1);
            }
            console.log(m);
        }
        
        function fn0(m){
            console.log(m);
           
            console.log(m);
        }

        // 递归求100的累加
        function sum(m){
            if(m == 1){
                return 1;
            }
            return m + sum(m-1);
        }

        console.log(sum(100)); // 5050

        // 100+99+98+97+....3+2+1

    </script>
</body>
</html>